#!/usr/bin/perl
use strict;
use DBI;

my $db       = "DBI:mysql:database=stock;host=192.168.37.128;port=3306";
my $userName = "whq";
my $dbh      = DBI->connect( $db, $userName )
  or die "Can't connect: " . DBI->errstr();

my $sql = "SELECT * FROM favorite f";
my $sth = $dbh->prepare($sql)
  or die "Can't prepare SQL statement: " . DBI->errstr();

$sth->execute() or die "Can't execute SQL statement: " . DBI->errstr();

#scalars that will be bound to columns
my ($name, $market, $code, $price, $des);

#need scalar references.
$sth->bind_columns(\$name, \$market, \$code, \$price, \$des);

while ( $sth->fetch() )
{
	print $name, "\t", $market, "\t",  $code, "\t", $price, "\t", $des . "\n";
}
$sth->finish();
$dbh->disconnect();
